'''
Created on 31.7.2011

@author: gilead
'''
from panda3d.core import Vec3,Point3,Vec4 #@UnresolvedImport

from Laser import Laser

class VisualEffects(object):
    def __init__(self, world):
        self.world = world
        self.lasers = Laser(self.world)
        
    def fireLaser(self, shooterGuid, shooterTurretID, targetGuid, offsetlength, offsetwidth):
        #print shooterGuid, shooterTurretID, targetGuid, offsetX, offsetY
        shooter = self.world.FindShip(shooterGuid)
        target = self.world.FindShip(targetGuid)
        if shooter == None or target == None:
            print "non-existent guid received in turret firing command"
            return
        turret = shooter.getTurret(shooterTurretID)
        if turret == None:
            print "non-existent turret id received in turret firing command"
            return
        
        offset = Vec3(offsetlength, offsetwidth, 0)
        
        # TODO: selvita seuraavat jostain.. vaikka turretin tiedoista?
        duration = 1.0
        width = 0.08
        color = Vec4(127/255,255/255,0,1)
        # add(duration, maxwidth, originTurret, tgtNodePath, tgtOffset, color):
        self.lasers.add(duration, width, turret, target, offset, color)